var _grid = $('#jgTable');

var _Data = [];
for(var i=0;i<10;i++){
    _Data.push({});
}

// 日历
$('.form_datetime').datetimepicker({
    //minView: "month", //选择日期后，不会再跳转去选择时分秒 
    language:  'zh-CN',
    format: 'yyyy-mm-dd',
    todayBtn:  1,
    autoclose: 1,
});

$(function(){
    _gridInit();
});

function alarmFormatter(cellvalue, options, rowdata){
    var grid = $(this);
    if(JSON.stringify(rowdata) !== '{}'){
        cellvalue = '<a href="javascript:0" opt-data="'+grid[0].id+'_delete" title="删除"><i class="fa fa-trash-o"></i></a>';
    }else{
        cellvalue = '';
    }
    return cellvalue;
}
function _gridInit(){
    var _gridData = Object.create(gridData);
    _gridData.grid = $('#jgTable');
    _gridData.datatype = "local";
    _gridData.rowNum = '100';
    _gridData.colModel = [
        {label:'基于类型', name:''},
        {label:'基于单号', name:''},
        {label:'基于行号', name:''},
        {label:'订单类型', name:''},
        {label:'客户代码', name:''},
        {label:'客户名称', name:''},
        {label:'单据日期', name:''},
        {label:'父物料代码', name:''},
        {label:'父物料描述', name:''},
        {label:'库存处理', name:''},
        {label:'物料代码', name:''},
        {label:'物料描述', name:''},
        {label:'商品规格', name:''},
        {label:'收款类别', name:''},
        {label:'发货仓库', name:''},
        {label:'未清数量', name:''},
        {label:'库存数量', name:''},
        {label:'可下数量', name:''},
        {label:'单位', name:''},
        {label:'操作', name:'Options', width:110, formatter:alarmFormatter, sortable:false}
    ];
    _gridData.scroll = true;
    _gridData.height = '390px';
    _gridData.beforeRequest = function(){
        _gridData.grid.jqGrid("setGridParam", {
            data : _Data,
        });
    };
    _gridData.loadComplete = function(xhr){
        xhr.Status == -999 && alert_QX($('body'), xhr.Message);
        gridSize();
    };
    gridInit(_gridData);
}

//样式
function gridSize(){
    _grid.setGridWidth($('hr').width());
}
